package com.galaxy.samson.staff.domain;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 * Created by IntelliJ IDEA.
 * User: madasamy
 * Date: 2/12/12
 * Time: 2:44 PM
 * To change this template use File | Settings | File Templates.
 */
@Entity
public class Staff
{
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;
    private String name;
    private String department;
    private String designation;
    private String phoneNo;

    public Staff()
    {
    }

    public Staff(String name, String department, String designation, String phoneNo) {
        this.name = name;
        this.department = department;
        this.designation = designation;
        this.phoneNo = phoneNo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public String getDesignation() {
        return designation;
    }

    public void setDesignation(String designation) {
        this.designation = designation;
    }

    public String getPhoneNo() {
        return phoneNo;
    }

    public void setPhoneNo(String phoneNo) {
        this.phoneNo = phoneNo;
    }

    @Override
    public String toString()
    {
      StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(getName()).append(",");
        stringBuilder.append(getDepartment()).append(",");
        stringBuilder.append(getDesignation()).append(",");
        stringBuilder.append(getPhoneNo());
        return stringBuilder.toString();
    }

    @Override
    public boolean equals(Object object)
    {
        if (object instanceof Staff)
        {
            Staff otherObject = (Staff) object;
            EqualsBuilder equalsBuilder = new EqualsBuilder();
            equalsBuilder.append(getDepartment(),otherObject.getDepartment());
            equalsBuilder.append(getDesignation(),otherObject.getDesignation());
            equalsBuilder.append(getName(),otherObject.getName());
            equalsBuilder.append(getPhoneNo(),otherObject.getPhoneNo());
            return equalsBuilder.isEquals();
        }
        return false;
    }

    @Override
    public int hashCode()
    {
        return HashCodeBuilder.reflectionHashCode(this);
    }
}
